//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================

#include <string.h>
#include <elatypes.h>

EXTERN_C char * CDECL strcat(char *dst, const char *src)
{
#ifdef _GNUC

#if defined(_x86)
    int temp0, temp1, temp2, temp3;
    ASM("repne;"
        "scasb;"
        "sub $1, %0;"//edi=edi-1
        "1:"
        "lodsb;"
        "stosb;"
        "testb %%al,%%al;"
        "jne 1b;"
        : "=D" (temp0), "=S" (temp1), "=a" (temp2), "=c" (temp3)
        : "0" (dst), "1" (src), "2" (0), "3" (0xffffffffu)
        :"memory");

    return dst;
#endif    //if defined(_x86)

#endif    //ifdef _GNUC

    char *d;
    if (!dst || !src)
        return dst;
    d = dst;
    for (; *d; d++);
    for (; *src; src++)
        *d++ = *src;
    *d = 0;

    return dst;
}
